<template>
    <a-form ref="formRef" @finish="handleFinish" :model="form" name="basic" :label-col="{ span: 8 }"
        :wrapper-col="{ span: 16 }" autocomplete="off">
        <a-row :gutter="16">
            <a-col :span="12">
                <a-form-item label="项目编号" name="proCode" :rules="[{ required: true }]">
                    <a-input v-model:value="form.proCode" disabled style="width: 100%" placeholder="" />
                </a-form-item>
            </a-col>

            <a-col :span="12">
                <a-form-item label="项目名称" name="proName">
                    <a-input-search v-model:value="form.proName" :disabled="disabled" style="width: 100%"
                        placeholder="请选择项目" />
                </a-form-item>
            </a-col>
        </a-row>
        <a-row :gutter="16">
            <a-col :span="12">
                <a-form-item label="投标结果" name="bidResult" :rules="[{ required: true }]">
                    <a-select :getPopupContainer="trigger => trigger.parentNode" v-model:value="form.bidResult" style="width: 100%">
                        <a-select-option value="1">中标</a-select-option>
                        <a-select-option value="0">未中标</a-select-option>
                    </a-select>

                </a-form-item>
            </a-col>

        </a-row>
        <a-row :gutter="16">
            <a-col :span="12">
                <a-form-item label="投标结果反馈人" name="bidFeedbacker">
                    <a-input v-model:value="form.bidFeedbacker" style="width: 100%" placeholder="" />
                </a-form-item>
            </a-col>
            <a-col :span="12">
                <a-form-item label="中标金额" name="bidAmount">
                    <a-input-number :precision="2" :min="0" v-model:value="form.bidAmount" style="width: 100%"
                        placeholder="" />
                </a-form-item>
            </a-col>
        </a-row>
        <a-row :gutter="16">

            <a-col :span="12">
                <a-form-item label="投标保证金" name="bidBond">
                    <a-input-number :precision="2" :min="0" v-model:value="form.bidBond" style="width: 100%"
                        placeholder="" />
                </a-form-item>
            </a-col>
            <a-col :span="12">
                <a-form-item label="中标时间" name="bidWinTime" >
                    <a-date-picker :getCalendarContainer="trigger => trigger.parentNode" valueFormat="YYYY-MM-DD hh:mm:ss" :disabled="disabled"
                        v-model:value="form.bidWinTime" style="width: 100%" placeholder="" />
                </a-form-item>
            </a-col>
        </a-row>

        <a-row :gutter="16" v-show="form.bidResult == 0">
            <a-col :span="24">
                <a-form-item :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }" label="丢标原因" name="bidLostReason">
                    <a-textarea v-model:value="form.bidLostReason" :disabled="disabled" :rows="4" placeholder=""
                        style="width: 100%" />
                </a-form-item>
            </a-col>
        </a-row>
    </a-form>
    <!-- <customerSelect ref="customerSelectRef" @OnClose="customerSelectOk" :value="form.customSelectRecords"></customerSelect> -->
</template>
<script setup>
import api from '@/api/pm/bid/index'
import { xmtypes, tbtypes } from '@/utils/constants.js'
const props = defineProps({
    value: {
        type: Object,
        default: () => { }
    },
    disabled: {
        type: Boolean,
        default: () => false
    }
})
const visible = ref(false)
const formRef = ref()
const show = (record) => {
    visible.value = true
    form.value = { ...record }
}

const submit = () => {
    formRef.value.validate().then(() => {
        handleFinish(form.value)
    }).catch((err) => {

    });
}
const form = ref({
});

const emits = defineEmits(['OnClose'])
const onClose = (refresh) => {
    visible.value = false;
    emits('OnClose', refresh)
};

const handleFinish = (values) => {
    api.input(values).then(() => {
        onClose(true);
    })
};

defineExpose({
    submit,
    show
})

</script>